<div class="address-edit-form">
  <form class="form-horizontal" data-type="addaddress" action="__SELF__">
  <input type="hidden" name="id" value="{$address.id}">
    <div class="form-group">
      <label for="" class="col-sm-2">收货人</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" name="name" placeholder="输入收货人姓名" value="{$address.name}">
      </div>
    </div>
    <div class="form-group">
      <label for="" class="col-sm-2">手机</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" name="phone" placeholder="收货人手机号码" value="{$address.phone}">
      </div>
    </div>
    <div class="form-group position">
      <label for="" class="col-sm-2">所在地区</label>
      <div class="col-sm-10">
      	{:hook('J_China_City',array('province'=>$address['province'],'city'=>$address['city'],'district'=>$address['district'],'community'=>$address['community']))}
      </div>
    </div>
    <div class="form-group">
      <label for="" class="col-sm-2">详细地址</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" name="address" placeholder="详细的收货地址" value="{$address.address}">
      </div>
    </div>
    <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-default">确 认</button>
    </div>
  </div>
  </form>
<script>
(function($){

  $('form[data-type="addaddress"]').submit(function (e) {
      e.preventDefault();
      toast.showLoading();
      var self = $(this);
      $.post(self.attr("action"), self.serialize(), callback, "json");
      return false;
  });
  
  function callback(data) {
    if (data.status) {
        toast.success(data.info, '温馨提示');
        setTimeout(function () {
            window.location.reload();
        }, 1000);
    }else{
        toast.error(data.info, '温馨提示');
    }
    toast.hideLoading();
  }
})(jQuery);
</script>
</div>

